package com.hgm.travelapp.activity

import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding

/**
 * @author    HGM
 * @version   1.0
 */
abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {

      private var context: Context? = null
      private var mBinding: T? = null

      override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            mBinding = getLayout()
            setContentView(mBinding!!.root)

            //初始化上下文
            context = application
            //初始化控件
            initView()
            //初始化数据
            initData()
      }

      abstract fun getLayout(): T

      abstract fun initView()

      abstract fun initData()

      override fun onDestroy() {
            super.onDestroy()
            mBinding = null
      }
}